package com.kcyu.sfherp.controller;

import com.kcyu.sfherp.entity.UserRecords;
import com.kcyu.sfherp.entity.utilEntity.PageEntity;
import com.kcyu.sfherp.service.UserRecordsService;
import com.kcyu.sfherp.utils.ResponseResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags="埋点接口")
@RequestMapping("/records")
public class RecordsController {

    @Autowired
    private UserRecordsService userRecordsService;

    @PostMapping("/addRecord")
    public ResponseResult addRecord(@RequestBody UserRecords userRecords) {
        ResponseResult responseResult = userRecordsService.addRecord(userRecords);
        return responseResult;
    }

    @PostMapping("/page")
    public ResponseResult<PageEntity<UserRecords>> page(@RequestBody PageEntity<UserRecords> pageEntity) {
        PageEntity<UserRecords> userRecordsPageEntity = userRecordsService.pageRecord(pageEntity);
        ResponseResult<PageEntity<UserRecords>> pageEntityResponseResult = new ResponseResult<PageEntity<UserRecords>>(200, "success", userRecordsPageEntity);
        return pageEntityResponseResult;
    }

}
